<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center editNameX_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub editNameX_fd0_0'>
					<view class='flex flex-wrap align-center editNameX_fd0_0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">
						<text class='fu-iconfont2  editNameX_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='editNameX_fd0_0_c1_c0'>修改昵称</text>
					</view>
					<view class='flex flex-wrap align-center justify-end editNameX_fd0_0_c0'
						@tap.stop="editUserNiknameFunc()">
						<text class='editNameX_fd0_0_c2_c0'>确定</text>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction align-stretch benben-flex-layout editNameX_flex_1">
				<view class='flex flex-wrap align-center editNameX_fd1_0'>
					<input class='editNameX_fd1_0_c0' type="text" :placeholder="`请输入`" confirm-type="done"
						:maxlength="7" placeholder-style="color:rgba(153, 153, 153, 1);font-size:28rpx"
						@input="valueInspectFunc($event)" v-model="userInfo.user_nickname" />
					<image class='editNameX_fd1_0_c1' mode="aspectFit" :src='STATIC_URL+"71.png"'></image>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"userInfo": {
					"invite_code": "",
					"address": "",
					"address_code": "",
					"hobby": "",
					"tags": "",
					"id": "",
					"userlevel_id": "",
					"mobile": "",
					"real_name": "",
					"avatar": "",
					"account": "",
					"email": "",
					"birthday": "",
					"gender": "",
					"create_time": "",
					"user_money": "",
					"freeze_money": "",
					"total_consumption_money": "",
					"score": "",
					"_mobile": "",
					"coupon": "",
					"collection_count": "",
					"browse_count": "",
					"total_money": "",
					"certified": "",
					"user_nickname": "",
					"is_pay_password": "",
					"follow_count": ""
				},
				"newUserInfo": {
					"userinfo": {
						"id": "",
						"avatar": "",
						"real_name": "",
						"user_nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"editname": "editname"
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//获取用户信息
			async getUserInfoFunc() {
				//请求方法
				//数据验证
				let datauserInfo = await this.$api.get(global.apiUrls.post5c78c4772da97, {

				});
				if (datauserInfo.data.code != 1) {
					this.$message.info(datauserInfo.data.msg);
					return
				}
				let infouserInfo = datauserInfo.data;
				this.userInfo = infouserInfo.data
			},
			//修改用户信息
			async editUserNiknameFunc() {
				if (!validate(this.userInfo.user_nickname, 'require')) {
					this.$message.info('请输入新昵称');
					return false;
				}
				if (!validate(this.userInfo.user_nickname, 'length', '1,7')) {
					this.$message.info('昵称不得超过七个字符');
					return false;
				}
				if (this.userInfo.user_nickname.split('').length < 2) {
					this.$message.info('最少2个字符');
					return
				}
				//请求方法
				//数据验证

				let datanewUserInfo = await this.$api.post(global.apiUrls.post5cb54af125f1c, {
					avatar: this.userInfo.avatar,
					nickname: this.userInfo.user_nickname,
					gender: this.userInfo.gender,
					birthday: this.userInfo.birthday,
					autograph: this.userInfo.hobby
				});

				if (datanewUserInfo.data.code != 1) {
					this.$message.info(datanewUserInfo.data.msg);
					return
				}
				let infonewUserInfo = datanewUserInfo.data;
				this.newUserInfo = infonewUserInfo.data
				this.$message.info('修改成功');
				uni.$emit('chengeName', this.editname)
				setTimeout(() => {
					this.$urouter.navigateBack(1);
				}, 500)
			},
			//监听输入框输入事件
			valueInspectFunc(e) {
				var str = e.detail.value
				var newZz = /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘'，。、]/gi;
				if (newZz.test(str)) {
					this.$nextTick(() => {
						this.userInfo.nickname = str.replace(newZz, '')

					})
					this.$message.info('昵称不能包含特殊字符');
					return;
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.editNameX_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.editNameX_fd0_0_c2_c0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 500;
	}

	.editNameX_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.editNameX_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.editNameX_fd0_0_c0 {
		width: 120rpx;
	}

	.editNameX_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.editNameX_flex_1 {
		padding: 24rpx 32rpx 24rpx 32rpx;
	}

	.editNameX_fd1_0_c1 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.editNameX_fd1_0_c0 {
		color: var(--benbenFontColor0);
		font-size: 28rpx;
	}

	.editNameX_fd1_0 {
		background: #FFFFFF;
		background-size: 100% auto !important;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 32rpx;
		width: 702rpx;
		height: 104rpx;
	}
</style>